﻿/********************************************************************
	created:	2011-8-15   14:10
	author:		Lifan Su
	
	purpose:	implement that changes hex digit into char
*********************************************************************/

#include <stddef.h>
#include "hex_to_char.h"
#include <assert.h>

char hex_to_char(int d)
{
    const static char chars[] = {
        '0', '1', '2', '3', '4', '5', '6', '7',
        '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
    };

    assert (d >= 0 && d < 16);

    return chars[d];
}

wchar_t hex_to_wchar(int d)
{
    const static wchar_t chars[] = {
        L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7',
        L'8', L'9', L'A', L'B', L'C', L'D', L'E', L'F'
    };

    assert (d >= 0 && d < 16);

    return chars[d];
}